<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var makeFancyString = function (s) {
      let ns = ''
      s.split('').forEach((v, i) => {
        if (ns.length < 2 || s[i - 1] != v || s[i - 2] != v) {
          ns += v;
        }
      })
      return ns;
    };
    console.log(makeFancyString("leeetcode"));
  </script>
</body>

</html>